package bao;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class DataBasePool {
    private static DataBasePool pool = new DataBasePool();

    private DataBasePool() {
    }

    public static DataBasePool getPool() {
        return pool;
    }

    public Connection getConnection() throws Exception {
        Properties pro = new Properties();
        InputStream in = DataBasePool.class.getClassLoader().getResourceAsStream("druid.properties");
        System.out.println(in);
        pro.load(in);
        DataSource dataSource = DruidDataSourceFactory.createDataSource(pro);
        Connection con = dataSource.getConnection();
        return con;
    }
}
